<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<!DOCTYPE HTML>
<html>
<head>

<title>My JSP 'menu.jsp' starting page</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>用户信息列表</title>

<script src="${pageContext.request.contextPath}/style/js/jquery.min.js"></script>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/amazeui.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/app.css">
<link
	href="${pageContext.request.contextPath}/style/css/bootstrap.min.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath}/style/layui/layui-tree2.0/layui/css/layui.css"
	rel="stylesheet">
<script
	src="${pageContext.request.contextPath}/style/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/style/js/amazeui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/style/layui/layui-tree2.0/layui/layui.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/style/layui/layui-tree2.0/layui-xtree/layui-xtree.js"></script>
</head>

<body>
	<form class="layui-form">
		<div id="menutree" class="xtree_contianer"></div>
		<br>
		<div>
			<button id="sub" style="position: absolute; left:80px" id="role"
				class="am-btn am-btn-primary am-btn-xs" type="button">
				<i class="glyphicon glyphicon-ok"></i>确定
			</button>
		</div>

	</form>
</body>
<script type="text/javascript">
	$(document)
			.ready(
					function() {
						layui
								.use(
										[ 'form', 'layer' ],
										function() {

											var form = layui.form;
											//获取节点数据  
											var layer = layui.layer;
											// 执行渲染  
											var menutree = new layuiXtree({
												elem : 'menutree' //(必填) 放置xtree的容器，样式参照 .xtree_contianer
												,
												form : form //(必填) layui 的 from
												,
												data : "rolemenu",
												ckall : true,
												icon : { //三种图标样式，更改几个都可以，用的是layui的图标
													open : "&#xe7a0;" //节点打开的图标
													,
													close : "&#xe622;" //节点关闭的图标
													,
													end : "&#xe621;" //末尾节点的图标
												},
												color : { //三种图标颜色，独立配色，更改几个都可以
													open : "#EE9A00" //节点图标打开的颜色
													,
													close : "#EEC591" //节点图标关闭的颜色
													,
													end : "#828282" //末级节点图标的颜色
												}

											});
											$("#sub")
													.click(
															function() {
																//获取全部[选中的][末级节点]原checkbox DOM对象，返回Array
																var oCks = menutree
																		.GetChecked(); //这是方法
																var id = new Array();
																for (var i = 0; i < oCks.length; i++) {
																	id[i] = oCks[i].value
																}
																layer
																		.open({
																			title : '修改权限',
																			content : '确定修改权限',
																			btn : [
																					'确认',
																					'取消' ],
																			yes : function(
																					index,
																					layero) {
																				var index = parent.layer
																						.getFrameIndex(window.name)
																				$
																						.ajax({
																							type : "post",
																							url : "${pageContext.request.contextPath}/role/editrolemenu",
																							data : {
																								ids : id
																							},
																							dataType : "text",
																							traditional : true,//这里设为true就可以了
																							success : function(
																									res) {
																								if (res == "success") {
																									layer
																											.alert(
																													'权限修改成功',
																													{
																														skin : 'layui-layer-molv' //样式类名
																														,
																														closeBtn : 0

																													},
																													function() {
																														parent.layer
																																.close(index);
																													});
																								}
																							},

																						});
																			}
																		});

															});

										});

					});
</script>
</html>
